package com.yunlankeji.stemcells.activity.home;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.yunlankeji.ganxibaozhijia.R;
import com.yunlankeji.stemcells.activity.mine.Address_editActivity;
import com.yunlankeji.stemcells.adapter.Expert_databaseAdapter;
import com.yunlankeji.stemcells.model.request.Expert_database;

import java.util.ArrayList;
import java.util.List;

public class Home_expert_classifyActivity extends AppCompatActivity {

    TextView tv_expert_classify_name,tv_expert_classify_position,tv_expert_classify_title;
    LinearLayout lt_expert_classify_return,item_lt_classify_expert;
    ImageView iv_expert_classify_picture;
    RecyclerView rv_expert_classify;
    TextView title;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home_expert_classify);

        tv_expert_classify_name=findViewById(R.id.tv_expert_name);
        tv_expert_classify_position=findViewById(R.id.tv_expert_position);
        tv_expert_classify_title=findViewById(R.id.tv_expert_title);
        lt_expert_classify_return=findViewById(R.id.lt_home_expert_classify_return);
        item_lt_classify_expert=findViewById(R.id.item_lt_expert_database);
        iv_expert_classify_picture=findViewById(R.id.iv_expert_picture);
        rv_expert_classify=findViewById(R.id.rv_expert_claccify);
        title = findViewById(R.id.tv_expert_classify_title);



        lt_expert_classify_return.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        String tv_tilt = getIntent().getStringExtra("title");

        title.setText(tv_tilt);


        List<Expert_database> expert_databasesList = new ArrayList<>();
        Expert_database expert_database1 = new Expert_database("123","123","生物化学及分子生物学博士， 中国医药学专家，专治各种疑难杂症",R.mipmap.icon_expert);
        Expert_database expert_database2 = new Expert_database("123","123","生物化学及分子生物学博士， 中国医药学专家，专治各种疑难杂症",R.mipmap.icon_expert);
        Expert_database expert_database3 = new Expert_database("123","123","生物化学及分子生物学博士， 中国医药学专家，专治各种疑难杂症",R.mipmap.icon_expert);
        Expert_database expert_database4 = new Expert_database("123","123","生物化学及分子生物学博士， 中国医药学专家，专治各种疑难杂症",R.mipmap.icon_expert);

        expert_databasesList.add(expert_database1);
        expert_databasesList.add(expert_database2);
        expert_databasesList.add(expert_database3);
        expert_databasesList.add(expert_database4);
        GridLayoutManager gridLayoutManager=new GridLayoutManager(Home_expert_classifyActivity.this,3);
        rv_expert_classify.setLayoutManager(gridLayoutManager);
        Expert_databaseAdapter expert_databaseAdapter= new Expert_databaseAdapter(expert_databasesList);


        rv_expert_classify.setAdapter(expert_databaseAdapter);

        // 设置item及item中控件的点击事件
        expert_databaseAdapter.setOnItemClickListener((Expert_databaseAdapter.OnItemClickListener) MyItemClickListener);

    }

    private Expert_databaseAdapter.OnItemClickListener MyItemClickListener = new Expert_databaseAdapter.OnItemClickListener() {
        @Override
        public void onItemClick(View v, Expert_databaseAdapter.ViewName viewName, int position) {
            switch (v.getId()){

                case R.id.item_lt_expert_database:
                    startActivity(new Intent(Home_expert_classifyActivity.this, Address_editActivity.class));
                    break;
            }

        }

        @Override
        public void onItemLongClick(View v) {

        }
    };
}